package com.shop.trade.atom.atomsvc.impl;

import com.shop.common.model.ServiceBean;
import com.shop.common.model.param.trade.OrderLogInput;
import com.shop.common.model.result.trade.OrderLogOutput;
import com.shop.common.tmpl.BaseService;
import com.shop.trade.atom.atomsvc.IOrderLogAtomSvc;
import com.shop.trade.atom.dao.OrderLogMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Description:
 *
 * @author zhoulk
 * @date: 2019年04月15日  0:16
 */
@Service
public class OrderLogAtom extends BaseService implements IOrderLogAtomSvc {
    @Autowired
    OrderLogMapper orderLogMapper;

    @Override
    public ServiceBean<Integer> addOrderLog(OrderLogInput orderLogInput) {
        Integer i = orderLogMapper.insertSelective(orderLogInput);
        if (i > 0) {
            return resultData(i);
        }
        return resultFailed();
    }

    @Override
    public ServiceBean<List<OrderLogOutput>> qryOrderLogs(OrderLogInput orderLogInput) {
        List<OrderLogOutput> orderLogOutputs = orderLogMapper.qryOrderLog(orderLogInput);
        if (orderLogOutputs != null && !orderLogOutputs.isEmpty()) {
            return resultData(orderLogOutputs);
        }
        return resultFailed();
    }

    @Override
    public ServiceBean<OrderLogOutput> qryOrderLog(Integer id) {
        OrderLogOutput orderLogOutput = orderLogMapper.selectByPrimaryKey(id);
        if (orderLogOutput != null) {
            return resultData(orderLogOutput);
        }
        return resultFailed();
    }
}
